<template>
  <section class="container">
    <div class="btnBox">
      <button class="btn">棠下服务区</button>
    </div>
    <div class="left">
      <div class="videoTop common">
        <img src="../assets/images/monitor/video-active.png" />
      </div>
      <!-- 点击摄像头的弹框 -->
      <div class="popBox">
        <div class="popTitle">
          <div class="text">卡口抓拍CCTV-01（XXXX服务区）</div>
          <span class="close">×</span>
        </div>
        <div class="popContent">
          <div class="chart" ref="popLine_Chart"></div>
        </div>
        <div class="popFooter"></div>
      </div>
    </div>
    <div class="right">
      <div class="videoBottom common">
        <img src="../assets/images/monitor/video-default.png" />
      </div>
      <!-- 右边的三个图 -->
      <div class="rightCharts">
        <div class="pieChart">
          <div class="title">在场危化品车辆数</div>
          <div class="com-chart" ref="pie_ref"></div>
        </div>
        <div class="rankChart">
          <div class="title">今日服务区告警排行</div>
          <div class="com-chart" ref="rank_ref">
            <div class="item">
              <span class="number">1</span>
              <div class="content">xxxxxxxxxxxxxxxxxxxxxxx</div>
              <span class="count">10次</span>
            </div>
            <div class="item">
              <span class="number">1</span>
              <div class="content">xxxxxxxxxxxxxxxxxxxxxxx</div>
              <span class="count">10次</span>
            </div>
            <div class="item">
              <span class="number">1</span>
              <div class="content">xxxxxxxxxxxxxxxxxxxxxxx</div>
              <span class="count">10次</span>
            </div>
            <div class="item">
              <span class="number">1</span>
              <div class="content">xxxxxxxxxxxxxxxxxxxxxxx</div>
              <span class="count">10次</span>
            </div>
            <div class="item">
              <span class="number">1</span>
              <div class="content">xxxxxxxxxxxxxxxxxxxxxxx</div>
              <span class="count">10次</span>
            </div>
          </div>
        </div>
        <div class="lineChart">
          <div class="title">最近7天危化品车进入趋势</div>
          <div class="com-chart" ref="line_ref"></div>
        </div>
      </div>
    </div>
  </section>
</template>

<script>
export default {
  name: 'ServeMonitor',
  data() {
    return {
      chartPieInstance: null,
      chartLineInstance: null,
      chartPopInstance: null
    }
  },
  mounted() {
    this.initPieChart()
    this.initLineChart()
    this.initPOpChart()
  },
  methods: {
    initPieChart() {
      this.chartPieInstance = this.$echarts.init(this.$refs.pie_ref)
      const option = {
        title: {
          text: '/辆',
          left: 126,
          top: 85,
          textStyle: {
            fontSize: 14,
            fontFamily: 'PingFangSC-Medium, PingFang SC',
            fontWeight: 500,
            color: '#FFB522',
            lineHeight: 25
          },
          background: '../assets/images/echarts-title.png'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          left: '60%',
          top: 'center',
          orient: 'vertical',
          textStyle: {
            fontSize: 14,
            fontFamily: ' PingFangSC-Regular, PingFang SC',
            fontWeight: 400,
            color: '#B6B7B7',
            lineHeight: 20,
            verticalAlign: 'center'
          },
          itemHeight: '8',
          icon: 'circle',
          formatter: function(name) {
            return name
          }
        },
        graphic: {
          type: 'text',
          left: '26%',
          top: '43%',
          style: {
            text: 8,
            textAlign: 'center',
            fill: '#FFB522',
            fontSize: 36,
            fontFamily: 'PingFangSC-Medium, PingFang SC',
            fontWeight: 500
          }
        },
        series: [
          {
            name: '访问来源',
            type: 'pie',
            center: ['30%', '50%'],
            radius: ['60%', '70%'],
            avoidLabelOverlap: true,
            itemStyle: {
              borderRadius: 50,
              borderColor: 'rgba(3, 12, 37, 0.81)',
              borderWidth: 2
            },
            lineStyle: {
              borderRadius: 50
            },
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: false,
                position: 'center'
              }
            },
            labelLine: {
              show: false
            },
            data: [
              {
                value: 3,
                name: '南区',
                itemStyle: {
                  color: '#0181fe'
                }
              },
              {
                value: 5,
                name: '北区',
                itemStyle: {
                  color: '#1bb390'
                }
              }
            ]
          }
        ]
      }
      this.chartPieInstance.setOption(option)
    },
    initLineChart() {
      this.initLineChart = this.$echarts.init(this.$refs.line_ref)
      const option = {
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          show: true,
          top: 15,
          left: 30,
          data: ['进入总数', '南区', '北区'],
          con: 'circle', //  这个字段控制形状  类型包括 circle，rect ，roundRect，triangle，diamond，pin，arrow，none
          itemWidth: 8, // 设置宽度
          itemHeight: 8, // 设置高度
          itemGap: 60, // 设置间距
          textStyle: {
            fontSize: 14,
            fontFamily: 'PingFangSC-Regular, PingFang SC',
            fontWeight: 400,
            color: '#BABABA',
            lineHeight: 20
          }
        },
        grid: {
          left: '3%',
          right: '10%',
          bottom: '5%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          splitLine: { show: false },
          axisLabel: {
            show: true,
            textStyle: {
              fontSize: 14,
              fontFamily: 'PingFangSC-Regular, PingFang SC',
              fontWeight: 400,
              color: '#B6B7B7',
              lineHeight: 20
            }
          },
          axisLine: {
            show: false,
            lineStyle: {
              color: '#979797',
              width: 1
            }
          },
          data: ['05-06', '05-07', '05-08', '05-09', '05-10', '05-11']
        },
        yAxis: {
          type: 'value',
          splitLine: {
            show: true,
            lineStyle: {
              color: ['#2d3345'],
              width: 1,
              type: 'solid'
            }
          },
          axisLabel: {
            show: true,
            textStyle: {
              fontSize: 14,
              fontFamily: 'PingFangSC-Regular, PingFang SC',
              fontWeight: 400,
              color: '#B6B7B7',
              lineHeight: 20
            }
          },
          axisLine: {
            show: false
          }
        },
        series: [
          {
            name: '进入总数',
            type: 'line',
            stack: '总量',
            symbol: 'none',
            itemStyle: {
              normal: {
                // color: '#8cd5c           2',
                lineStyle: {
                  color: '#FFB522'
                }
              }
            },
            data: [20, 32, 10, 34, 20, 30]
          },
          {
            name: '南区',
            type: 'line',
            stack: '总量',
            symbol: 'none',
            itemStyle: {
              normal: {
                // color: '#8cd5c2', // 改变折线点的颜色
                lineStyle: {
                  color: '#0181FF' // 改变折线颜色
                }
              }
            },
            data: [20, 71, 37, 23, 29, 33]
          },
          {
            name: '北区',
            type: 'line',
            stack: '总量',
            symbol: 'none',
            itemStyle: {
              normal: {
                // color: '#8cd5c2', // 改变折线点的颜色
                lineStyle: {
                  color: '#1DBC97' // 改变折线颜色
                }
              }
            },
            data: [50, 32, 20, 54, 30, 33]
          }
        ]
      }
      this.initLineChart.setOption(option)
    },
    initPOpChart() {
      this.chartPopInstance = this.$echarts.init(this.$refs.popLine_Chart)
      const option = {
        title: {
          text: '过车趋势图',
          top: 0,
          left: 0,
          textStyle: {
            fontSize: 16,
            fontFamily: ' PingFangSC-Medium, PingFang SC',
            fontWeight: 500,
            color: '#2C313C',
            lineHeight: 22
          }
        },
        tooltip: {
          trigger: 'axis',
          formatter: function(args) {
            return args[0].axisValue + '\n' + args[0].value + '/辆'
          }
        },
        grid: {
          left: '1%',
          right: '1%',
          bottom: '5%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          splitLine: {
            show: true,
            lineStyle: {
              color: ['#DBDDE0'],
              width: 1,
              type: 'dashed'
            }
          },
          axisLabel: {
            show: true,
            textStyle: {
              fontSize: 14,
              fontFamily: 'PingFangSC-Regular, PingFang SC',
              fontWeight: 400,
              color: '#999999',
              lineHeight: 20
            }
          },
          axisLine: {
            show: true,
            lineStyle: {
              color: ['#DBDDE0']
            }
          },
          data: ['1:00', '3:00', '5:00', '7:00', '9:00', '11:00']
        },
        yAxis: {
          type: 'value',
          splitLine: {
            show: true,
            lineStyle: {
              color: ['#DBDDE0'],
              width: 1,
              type: 'dashed'
            }
          },
          axisLabel: {
            show: true,
            textStyle: {
              fontSize: 14,
              fontFamily: 'PingFangSC-Regular, PingFang SC',
              fontWeight: 400,
              color: '#999999',
              lineHeight: 20
            }
          },
          axisLine: {
            show: false
          }
        },
        series: [
          {
            name: '进入总数',
            type: 'line',
            stack: '总量',
            symbolSize: 10,
            itemStyle: {
              normal: {
                color: '#009BE5',
                lineStyle: {
                  color: '#009BE5'
                }
              }
            },
            data: [20, 32, 10, 34, 20, 30]
          }
        ]
      }
      this.chartPopInstance.setOption(option)
    }
  }
}
</script>

<style lang="less" scoped>
.com-chart {
  width: 100%;
  height: calc(100% - 53px);
  margin-top: -10px;
}
.title {
  width: 379px;
  height: 35px;
  padding-left: 22px;
  padding-top: 5px;
  padding-bottom: 5px;
  margin-left: 20px;
  margin-top: 18px;
  margin-right: 31px;
  font-size: 18px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #ffffff;
  line-height: 25px;
  background: url(../assets/images/monitor/echarts-title.png) no-repeat;
}
.container {
  width: 100%;
  min-height: calc(100vh - 94px);
  background: url(../assets/images/monitor/monitor-map.png) no-repeat
    center/100% 100%;
  overflow-y: scroll;
}
.btnBox {
  position: relative;
  height: 40px;
}
.btn {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 120px;
  height: 40px;
  background: #2194ff;
  border-radius: 22px;
  font-size: 18px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #ffffff;
  line-height: 25px;
  border: none;
  margin-top: 10px;
}
.left,
.right {
  position: relative;
  height: 100%;
}
.left .videoTop {
  top: 3px;
  left: 580px;
}

.common {
  position: absolute;
  width: 48px;
  height: 48px;
  img {
    width: 100%;
    height: 100%;
    display: block;
  }
}
.right .videoBottom {
  bottom: -810px;
  right: 620px;
}
.rightCharts {
  position: absolute;
  right: 32px;
  top: 0px;
  .pieChart,
  .rankChart,
  .lineChart {
    width: 430px;
    border: 1px solid;
    border-image: linear-gradient(
        180deg,
        rgba(12, 71, 105, 1),
        rgba(206, 232, 255, 1)
      )
      1 1;
  }
  .pieChart {
    height: 240px;
    background: rgba(3, 12, 37, 0.81);
    border-radius: 11px;
    opacity: 0.89;
    margin-bottom: 16px;
  }
  .rankChart {
    width: 430px;
    height: 270px;
    background: #030c25;
    border-radius: 12px;
    opacity: 0.89;
    margin-bottom: 16px;
    .item {
      width: 379px;
      margin-left: 20px;
      margin-top: 18px;
      margin-right: 31px;
      display: flex;
      font-family: PingFangSC-Regular, PingFang SC;
      .number {
        width: 22px;
        height: 22px;
        background: rgba(0, 0, 0, 0.17);
        border-radius: 2px;
        border: 1px solid rgba(177, 189, 200, 0.34);
        font-size: 16px;
        font-weight: 400;
        color: #ff6524;
        line-height: 20px;
        text-align: center;
        margin-right: 22px;
      }
      .count {
        width: 36px;
        height: 20px;
        font-size: 14px;
        font-weight: 400;
        color: #009be5;
        line-height: 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.16);
      }
      .content {
        flex: 1;
        font-size: 14px;
        height: 20px;
        line-height: 20px;
        font-weight: 400;
        color: #cccccc;
        border-bottom: 1px solid rgba(255, 255, 255, 0.16);
        padding-left: 10px;
      }
    }
  }
  .lineChart {
    width: 430px;
    height: 300px;
    background: #030c25;
    border-radius: 14px;
    margin-right: 20px;
  }
}
// 点击摄像头的弹框
.popBox {
  position: absolute;
  top: 80px;
  left: 20px;
  width: 712px;
  height: 548px;
  background: #ffffff;
  box-shadow: 0px 8px 17px 0px rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  border: 1px solid #dbdde0;
  .popTitle {
    width: 710px;
    height: 61px;
    background: #f9f9fa;
    border-radius: 6px 6px 0px 0px;
    padding: 18px 21px 21px 23px;
    box-sizing: border-box;
    border-bottom: 1px solid #d1d7da;
    .text {
      float: left;
      font-size: 16px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #2c313c;
      line-height: 22px;
    }
    .close {
      float: right;
      font-size: 20px;
      color: #2c313c;
      margin-top: -5px;
    }
  }
  .popContent {
    width: 100%;
    height: 275px;
    padding: 16px 21px 21px 23px;
    box-sizing: border-box;
    .chart {
      width: 100%;
      height: 100%;
    }
  }
  .popFooter {
    width: 100%;
    height: 212px;
    padding: 16px 21px 21px 23px;
    box-sizing: border-box;
  }
}
</style>
